import api from './api';

export interface DiscussListParams {
  page?: number;
  type?: number; // 1-按点赞数排序(默认)，2-按时间排序
}

export interface DiscussDetailParams {
  did: number;
}

export interface DiscussAddParams {
  title: string;
  content: string;
  tags?: string[];
}

export interface DiscussDeleteParams {
  did: number;
}

export interface DiscussSupportParams {
  did: number;
}

export interface CommentAddParams {
  did: number;
  content: string;
}

export interface CommentDeleteParams {
  cid: number;
}

// 获取讨论列表
export const getDiscussList = (params: DiscussListParams = {}) => {
  return api.post('/discuss/list', params);
};

// 获取讨论详情
export const getDiscussDetail = (params: DiscussDetailParams) => {
  return api.post('/discuss/detail', params);
};

// 添加讨论
export const addDiscuss = (params: DiscussAddParams) => {
  return api.post('/discuss/add', params);
};

// 获取我的讨论列表
export const getMyDiscussList = () => {
  return api.post('/discuss/mylist');
};

// 删除讨论
export const deleteDiscuss = (params: DiscussDeleteParams) => {
  return api.post('/discuss/delete', params);
};

// 点赞讨论
export const supportDiscuss = (params: DiscussSupportParams) => {
  return api.post('/discuss/support', params);
};

// 添加评论
export const addComment = (params: CommentAddParams) => {
  return api.post('/comment/add', params);
};

// 删除评论
export const deleteComment = (params: CommentDeleteParams) => {
  return api.post('/comment/delete', params);
}; 